package com.guigu.controller.manufacture;


import com.guigu.pojo.manufacture.MDesignProcedure;
import com.guigu.pojo.manufacture.MDesignProcedureDetails;
import com.guigu.service.manufacture.MDesignProcedureDetailsService;
import com.guigu.service.manufacture.MDesignProcedureService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mr.Zhang
 * @since 2024-12-06
 */
@Controller
@RequestMapping("/m-design-procedure-details")
public class MDesignProcedureDetailsController {

    @Autowired
    private MDesignProcedureService mDesignProcedureService;

    @Autowired
    private MDesignProcedureDetailsService mDesignProcedureDetailsService;

    @GetMapping("/selectArrByParentId")
    @ResponseBody
    private ArrayList<MDesignProcedureDetails> selectArrByParentId(HttpServletRequest req){
        Integer id = StringUtils.isNotBlank(req.getParameter("id")) ? Integer.parseInt(req.getParameter("id")) : null;
        ArrayList<MDesignProcedureDetails> mDesignProcedureDetails = mDesignProcedureDetailsService.selectArrByParentId(id);
        return mDesignProcedureDetails;
    }

    @PostMapping("/audit")
    @ResponseBody
    private Boolean audit(@RequestBody HashMap<String, Object> map) {
        System.out.println(map);
        String id = (String) map.get("id");
        String checkTag = (String) map.get("checkTag");
        String register = (String) map.get("register");
        String checkSuggestion = (String) map.get("checkSuggestion");
        MDesignProcedure mDesignProcedure = new MDesignProcedure();
        mDesignProcedure.setId(Integer.parseInt(id));
        mDesignProcedure.setDesignModuleTag(checkTag);
        mDesignProcedure.setChanger(register);
        mDesignProcedure.setChangeTime(new Date());
        mDesignProcedure.setCheckSuggestion(checkSuggestion);
        boolean b = mDesignProcedureService.updateById(mDesignProcedure);
        return b;
    }


}

